import javax.swing.JFrame;
import javax.swing.JButton;
import java.awt.Color;
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.FlowLayout;
import javax.swing.JTextField;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.JLabel;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent; 
import javax.swing.JRadioButton;
import javax.swing.JTextArea;
import javax.swing.JScrollPane;
import javax.swing.Box;

public class Ihm implements ActionListener {
  
	private JButton start = new JButton ("Start");
	private JButton stop = new JButton ("Stop");
  private JTextField ttl = new JTextField(3);
  private JTextField file = new JTextField(3);
  private JTextField memory = new JTextField(3);
  private JTextField sensor = new JTextField(3);
  private JTextField step = new JTextField(3);
  private JTextArea textAreaSim = new JTextArea(18,40);
  
  public Ihm() {
    JFrame fenetre = new JFrame ("TP Sensor");
    JLabel JLabTTL= new JLabel("TTL d'un paquet :");
    
    //Disposition de notre fenetre
    fenetre.setLayout(new GridLayout(2,2));
    
    //Parmametre
    JPanel panelParam = new JPanel();
    panelParam.setLayout(new FlowLayout(10, 10, 10));
    panelParam.setBorder(BorderFactory.createTitledBorder("Parametrage"));
    
    Box vert1 = Box.createVerticalBox ();
    vert1.add(new JLabel("TTL Max/Paquet  :"));
    vert1.add (Box.createVerticalStrut(15)) ;
    vert1.add(new JLabel("Taille Max. File/Capteur  :"));
    vert1.add (Box.createVerticalStrut(15)) ;
    vert1.add(new JLabel("Taille Max. Mémoire/Capteur  :"));
    vert1.add (Box.createVerticalStrut(15)) ;
    vert1.add(new JLabel("Nombre de Capteurs/Simulation  :"));
    vert1.add (Box.createVerticalStrut(15)) ;
    vert1.add(new JLabel("Nombre de pas/Simulation  :"));

    Box vert2 = Box.createVerticalBox ();
    vert2.add(ttl);
    vert2.add (Box.createVerticalStrut(10)) ;
    vert2.add(file);
    vert2.add (Box.createVerticalStrut(10)) ;
    vert2.add(memory);
    vert2.add (Box.createVerticalStrut(10)) ;
    vert2.add(sensor);
    vert2.add (Box.createVerticalStrut(10)) ;
    vert2.add(step);
    
    panelParam.add(vert1);
    panelParam.add(vert2);
    
    //Action
    JPanel panelAction = new JPanel();
    panelAction.setLayout(new GridLayout(4,6,10,10));
    panelAction.setBorder(BorderFactory.createTitledBorder("Action"));
    panelAction.add(start);
    panelAction.add(stop);
    
    //Simulation
    JPanel panelSimu = new JPanel();
    panelSimu.setLayout(new BorderLayout());
    panelSimu.setBorder(BorderFactory.createTitledBorder("Simulation"));
    panelSimu.add(textAreaSim, BorderLayout.CENTER);
    JScrollPane scrollpane=new JScrollPane(textAreaSim,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    //textAreaSim.setEditable(false);
    panelSimu.add(scrollpane);
    
    fenetre.add(panelParam);
    fenetre.add(panelAction);
    fenetre.add(panelSimu);
    fenetre.setSize(800,600);
    fenetre.setResizable(false);
    fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    fenetre.show();
		fenetre.setVisible(true);
  }
  
  public void actionPerformed(ActionEvent e) {
  }
}
